package com.evon.yardmanagement.ui.action;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.Map;

import org.apache.struts2.interceptor.ParameterAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
/**
 * Base class for export action.
 * @author vgaurav
 *
 */
public abstract class BaseExportAction extends ActionSupport implements ParameterAware,
		SessionAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	//File stream for exporting the file.
	protected InputStream fileStream;

	public InputStream getFileStream() {
		fileStream = new ByteArrayInputStream(exportDataToExcelFile()
				.toByteArray());
		return fileStream;
	}
	
	/**
	 * Abstract method which the implementing class will provide.
	 * @return
	 */
	
	public abstract ByteArrayOutputStream exportDataToExcelFile();
	

	public void setFileStream(InputStream fileStream) {
		this.fileStream = fileStream;
	}

	public void setParameters(Map<String, String[]> parameters) {
		// TODO Auto-generated method stub

	}

	public void setSession(Map<String, Object> session) {
		// TODO Auto-generated method stub

	}

}
